import request from '@/utils/request'
import fileRequest from '@/utils/fileRequest'

/*TODo 注意,如果是psot请求,不加params  ,get请求需要加上*/

// 用户绑定角色
export function page(obj) {
  return request({
    url: '/buttonPermission/page',
    method: 'get',
    params: obj
  })
}


//启用/禁用按钮权限
export function changeButton(obj) {
  let data = {
    "type": obj.type,
    "id": obj.id
  };
  return request({
    url: '/buttonPermission/changeButton',
    method: 'put',
    params: data
  });
}


//查询详情
export function getDetail(id) {
  let data = {
    'id': id
  };
  return request({
    url: '/buttonPermission/getDetail',
    method: 'get',
    params: data
  });
}

//新增/修改按钮权限
export function saveOrUpdate(obj) {
  let data = {
    'id': obj.id,
    'summary': obj.summary,
    "url": obj.url,
    "menuId": obj.menuId
  };
  return request({
    url: '/buttonPermission/saveOrUpdate',
    method: 'post',
    data
  });
}

//新增/修改按钮权限
export function deleteButton(id) {
  let data = {
    'id': id + '',
  };
  return request({
    url: '/buttonPermission/delete',
    method: 'delete',
    params: data
  });
}

//查询按钮权限list
export function buttonList(obj) {
  let data = {
    'menuId': obj.menuId,
    'roleId':obj.roleId,
  };
  return request({
    url: '/buttonPermission/buttonList',
    method: 'get',
    params: data
  });
}

//角色赋值按钮权限
export function setButton(obj) {
  let data = {
    'roleId': obj.roleId,
    "idList":obj.idList
  };
  return request({
    url: '/buttonPermission/setButton',
    method: 'post',
    data
  });
}
